import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';

// 权限工具类
class PermissionUtils {

  // 请求相册
  static Future requestPhotos() async {
    // 检测权限
    var status = await Permission.photos.request();
    return status;
  }

  // 请求摄像头
static Future requestCamera() async {
    var status = await Permission.camera.request();
    return status;
}

// 显示权限弹出框
static showPermissionDialog(BuildContext context,{text:'无法正常访问，因为没有权限'}) {
    showDialog(
    context:context,
    builder: (context) {
      return AlertDialog(
        title: Text('警告'),
        content: Text(text),
        actions: <Widget>[
          FlatButton(onPressed: () {openAppSettings();}, child: Text('去设置')),
        ],
      );
    });
}






}

